package com.ushine.web.template.transactional.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ushine.web.template.transactional.mapper.FirstTransactionMapper;
import com.ushine.web.template.transactional.service.IFirstTransactionService;
import com.ushine.web.template.transactional.model.FirstTransactionDO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author: yls
 * @Date 2022/2/14 11:09
 * @Description: 模拟事务实现类
 * @Version 1.0
 **/
@Service
public class FirstTransactionServiceImpl extends ServiceImpl<FirstTransactionMapper, FirstTransactionDO>
        implements IFirstTransactionService {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void insert(FirstTransactionDO firstTransaction) {
        save(firstTransaction);
    }

    @Override
    @Transactional(readOnly = true)
    public List<FirstTransactionDO> listFirstTransactions() {
        return list();
    }
}
